<?php

class SettingController extends Controller {
    public $layout = '//layouts/setting';
    public $defaultAction = 'account';

    public function actionAccount() {
        $this->render('account');
    }
    
    public function actionPassword() {
        $this->render('password');
    }
    
    public function actionMobile() {
        $this->render('mobile');
    }
    
    public function actionNotification() {
        $this->render('notification');
    }
    
    public function actionProfile() {
        $model  = TUsers::model()->findByPk(Yii::app()->user->id);
        
        if (isset($_POST['TUsers'])){
            $model ->attributes = $_POST['TUsers'];
            if ($model->save()){
                Yii::app()->user->setFlash('success', 'Edit profile successfully');
            }
            else
                Yii::app()->user->setFlash('error'  , 'Edit profile fail');
        }
        $this->render('profile', array(
            'model'=>$model,
        ));
    }
    
    public function actionDesign() {
        $this->render('design');
    }
    
    public function actionApplications() {
        $this->render('applications');
    }
    
    
    
    public function filters() {
        return array(
            'accessControl',
        );
    }
    
    public function accessRules() {
        return array(
            array('allow', // allow authenticated users to access all actions　　（　されたユーザーはすべてのアクションへのアクセスを許可する　）
                'users' => array('@'),
            ),
            array('deny', // deny all users　(すべてのユーザーを拒否する。)
                'users' => array('*'),
            ),
        );
    }

}